package com.tengju.bff.interfaces.covercharge.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * @author liang_shi
 * @date 2020/8/31 23:34
 * @description 收益来源
 */
@Getter
@AllArgsConstructor
public enum ProfitFromEnum {

    /**
     * 收益结算
     */
    FROM_1(1, "收益结算", Boolean.TRUE),

    /**
     * 市场补贴-php
     */
    FROM_2(2, "市场补贴", Boolean.FALSE),

    ;

    /**来源*/
    private Integer from;

    /**描述*/
    private String msg;

    /**是否需要发送Mq*/
    private Boolean needSendMq;


    /**
     * 根据来源获取指定枚举
     *
     * @param from 来源
     * @return 结果
     */
    public static ProfitFromEnum getInstance(Integer from) {
        if (Objects.isNull(from)) {
            return null;
        }
        for (ProfitFromEnum fromEnum : ProfitFromEnum.values()) {
            if (fromEnum.getFrom().equals(from)) {
                return fromEnum;
            }
        }
        return null;
    }


}
